-
Notifications
You must be signed in to change notification settings - Fork 2
/
pre-commit_autoupdate.yml
42 lines (42 loc) · 1.22 KB
/
pre-commit_autoupdate.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
name: Pre-commit auto-update
# PAT github secret has to be created with repo scope
# add the secret to the repo settings
on:
# every monday
schedule:
- cron: "0 7 * * 1"
# on demand
workflow_dispatch:
#{% raw %}
jobs:
pre-commit-update:
runs-on: ubuntu-latest
name:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Update pre-commit hooks
uses: brokenpip3/action-pre-commit-update@0.0.1
with:
github-token: ${{ secrets.PAT }}
- name: Add label
uses: actions/github-script@v7
with:
github-token: ${{ secrets.PAT }}
script: |
const { data: pullRequests } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
state: 'open',
head: 'auto-update-pre-commit-hooks'
});
if (pullRequests.length > 0) {
const prNumber = pullRequests[0].number;
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: prNumber,
labels: ['automerge']
});
}
#{% endraw %}